//
//  SelfViewManager.m
//  17DianYing
//
//  Created by apple on 15/9/14.
//  Copyright (c) 2015年 apple. All rights reserved.
//

#import "SelfViewManager.h"
#import "AFNetworking.h"

@interface SelfViewManager ()
@property(nonatomic,strong)AFHTTPRequestOperationManager *afManager;
@property(nonatomic,strong)SelfViewManager *selfM;

@end
@implementation SelfViewManager


+(instancetype)share
{
    static SelfViewManager *m = nil;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        m = [[SelfViewManager alloc]init];
    });
    return m;
}

-(void)getSelfWithToken:(NSString *)token BlockHoudle:(SelfManagerBlock)hb;
{
    self.afManager = [[AFHTTPRequestOperationManager alloc]init];
    self.afManager.responseSerializer = [AFHTTPResponseSerializer serializer];
    
    NSString * url =[http stringByAppendingString:@"/mobile/user/getMyUserInfo"];
    
    NSDictionary * dic =  @{@"token":token};
    AFHTTPRequestOperation *op = [self.afManager GET:url parameters:dic success:^(AFHTTPRequestOperation *operation, id responseObject) {
        
        id obj = [NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingAllowFragments error:nil];
        
        NSDictionary *dic = obj;
        hb(dic);
        [op start];
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        NSLog(@"%@",error.localizedDescription);
    }];

}
@end
